package dd.view;
import java.awt.EventQueue;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;

import dd.control.CreateEventButtonController;
import dd.control.JoinButtonController;
import dd.model.Event;
import dd.model.Model;


public class MainScreen extends JFrame {

	private JPanel contentPane;
	Event event;
	private JTextField idTextField;
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Model model = Model.getInstance();
					Event e = model.getEvent();
					MainScreen frame = new MainScreen(e);
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public MainScreen(Event event) {
		this.event = event;
		setTitle("Main Screen DD ");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JButton btnCreate = new JButton("Create");
		btnCreate.setBounds(21, 59, 117, 29);
		contentPane.add(btnCreate);
		
		
		btnCreate.addActionListener(new CreateEventButtonController(this, event));
		
		
		JButton btnAdministration = new JButton("Administration");
		btnAdministration.setBounds(256, 59, 147, 29);
		contentPane.add(btnAdministration);
		
		JButton btnJoin = new JButton("Join");
		btnJoin.setBounds(21, 171, 117, 29);
		contentPane.add(btnJoin);
		btnJoin.addActionListener(new JoinButtonController(this, event));
	
		idTextField = new JTextField();
		idTextField.setText("");
		idTextField.setBounds(256, 175, 138, 20);
		contentPane.add(idTextField);
		idTextField.setColumns(10);
		
	}
	

	public JTextField getIDTextField(){
		return idTextField;
	}
}
